<template>
    <div>
        <el-menu default-active="2" class="el-menu-vertical-demo" background-color="#545c64" text-color="#fff"
            unique-opened router :collapse-transition="false" :collapse="isCollapse" active-text-color="#ffd04b">
            <el-submenu :index="index + ''" v-for="item, index in treeList " :key="item.id">
                <template slot="title">
                    <i class="el-icon-location"></i>
                    <span>{{ item.authName }}</span>
                </template>
                <el-menu-item-group v-for="it in item.children" :key="it.id">
                    <el-menu-item :index="it.path + ''">{{ it.authName }}</el-menu-item>
                </el-menu-item-group>
            </el-submenu>
        </el-menu>
    </div>
</template>

<script>
import { rightsApi } from '@/api/home';
import { mapState } from 'vuex';
export default {
    name: 'MyAppRightsCom',

    data() {
        return {
            treeList: [],//左侧菜单数据
        };
    },
    computed: {
        ...mapState('login', ['isCollapse'])
    },
    mounted() {
        this.getRightsList()
    },

    methods: {
        async getRightsList() {
            let res = await rightsApi()
            this.treeList = res
        }
    },
};
</script>

<style lang="scss" scoped>

</style>